import * as Koa from 'koa';
import * as Router from 'koa-router';
import * as bodyParser from 'koa-bodyparser';
import {AppRoutes} from './routers';

const app = new Koa();
const router = new Router();

AppRoutes.forEach(route => router[route.method](route.path, route.action));

try {
    app.use(bodyParser());
    app.use(router.routes());
    app.use(router.allowedMethods());
    app.listen(3000);

    console.log('Application is up and running on port 3000');
} catch (err) {
    console.error(err)
}
